package com.company.huisuo.biz.adapter

import android.view.LayoutInflater
import android.view.ViewGroup
import com.company.huisuo.base.BaseSingleAdapter
import com.company.huisuo.databinding.ItemSelectRoomBinding


class SelectRoomAdapter : BaseSingleAdapter<String, ItemSelectRoomBinding>() {

    private var mSelectPos = 6
    private var mUnablePos = arrayListOf(4)

    override val initViewBinding: (LayoutInflater, ViewGroup, Boolean) -> ItemSelectRoomBinding
        get() = ItemSelectRoomBinding::inflate

    override fun convert(
        holder: SingleViewHolder<ItemSelectRoomBinding>, position: Int, item: String?
    ) {
        holder.binding.apply {
            tvContent.text = item ?: ""
            tvContent.isEnabled = !mUnablePos.contains(position)
            tvContent.isSelected = mSelectPos == position
            tvContent.setOnClickListener {
                mSelectPos = if (mSelectPos == position) {
                    -1
                } else {
                    position
                }
                notifyDataSetChanged()
            }
        }
    }
}